package com.jgp.sys.query.power;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 项目   jgp-cloud-parent
 * 作者   loufei
 * 时间   2019-11-15
 */
@Setter
@Getter
public class DataPowerConfig {
    
    private boolean enabled = true;
    
    List<Group> groups = new ArrayList<>();
    
    public void or(DataPowerItem ... items){
        Group group = new Group(DataPowerOperator.OR, Arrays.asList(items));
        groups.add(group);
    }
    
    public void and(DataPowerItem ... items){
        Group group = new Group(DataPowerOperator.AND, Arrays.asList(items));
        groups.add(group);
    }
    
    @Setter
    @Getter
    @AllArgsConstructor
    public class Group {
        DataPowerOperator operator;
        List<DataPowerItem> items;
    }
}
